import ResurgenceWindow_Generate from "../ui-generate/ResurgenceWindow_generate";
import { Tween } from "../etc/Tween";

export class ResurgenceWindow extends ResurgenceWindow_Generate{
    private callback:Function
    private callback1:Function
    private caller:any

    private tweened = false

    private tween:Tween<{t:number}> = new Tween({t:0.3}).to({t:0.95}, 800).onUpdate(obj=>{
        this.btn_bg.renderOpacity = obj.t
    })

    onStart(){
        this.btn_checkpoint_resurgence.onClicked.add(()=>{
            UIService.hideUI(this)
            this.callback.call(this.caller)
        })
        this.btn_last_jump_resurgence.onClicked.add(()=>{
            UIService.hideUI(this)
            this.callback1.call(this.caller)
        })
    }

    onShow(){
        if(this.tweened == true) return
        this.tween.start()
        this.tweened = true
    }

    onHide(){
        this.tweened = false
    }

    setInfo(callback:Function, callback1:Function, caller:any){
        this.callback = callback
        this.callback1 = callback1
        this.caller = caller
    }
}